.PHONY: help install dev test lint format clean run

# 默认目标
help:
	@echo "Available commands:"
	@echo "  install     - Install dependencies"
	@echo "  dev         - Install development dependencies"
	@echo "  test        - Run tests"
	@echo "  lint        - Run linting (flake8, mypy)"
	@echo "  format      - Format code (black, isort)"
	@echo "  clean       - Clean cache and build files"
	@echo "  run         - Run the application"

# 安装依赖
install:
	uv sync

# 安装开发依赖
dev:
	uv sync --extra dev

# 运行测试
test:
	uv run pytest

# 代码检查
lint:
	uv run flake8 src tests
	uv run mypy src

# 代码格式化
format:
	uv run black src tests
	uv run isort src tests

# 清理缓存
clean:
	Find-ChildItem -Path . -Name "__pycache__" -Recurse | Remove-Item -Recurse -Force
	Find-ChildItem -Path . -Name "*.pyc" -Recurse | Remove-Item -Force
	Find-ChildItem -Path . -Name ".pytest_cache" -Recurse | Remove-Item -Recurse -Force
	Find-ChildItem -Path . -Name ".mypy_cache" -Recurse | Remove-Item -Recurse -Force

# 运行应用
run:
	uv run uvicorn main:app --reload --host 0.0.0.0 --port 8088